<template>
  <base-modal
    :width="modAlProps.width"
    :isVisible="props.isVisible"
    :title="modAlProps.title"
    :buttons="buttons"
    :cancleText="'关闭'"
    @handleCancle="handleCancle"
    class="operatingRecord_modal"
  >
    <template v-slot:body>
      <div class="operatingRecordBox">
        <treeTable
          :columns="columns.operatingRecordColumn"
          :dataSource="resData"
          isSelect="false"
          :scroll="scroll"
          ref="tagBaseTables"
          :rowSelection="1"
        >
          <template #bodyCell="{ column, text, record }">
            <template v-if="column.dataIndex === 'opType'">
              <span>{{ getRecordValue(text) }}</span>
            </template>
          </template>
        </treeTable>
      </div>
    </template>
  </base-modal>
</template>

<script lang="ts" setup>
import { ref, reactive, nextTick, onMounted, defineComponent, watch } from "vue";
import baseModal from "@/components/modal/baseModal.vue";
import treeTable from "@/components/table/baseTable.vue";
import columns from "@/components/table/tableConfig/tableColumn/contentManageColumn";
import tableToolTip from "@/components/table/tableToolTip.vue";
import { scrollType } from "@/type.d";
import { dataSourceType, detailDataItemType } from "@/type";
import request from "@/api/index";
import { Modal, message } from "ant-design-vue";
import { number } from "echarts";
const props = defineProps({
  isVisible: {
    type: Boolean,
    default: false,
  },
  contentId: {
    type: Number,
    default: null,
  },
});
const resData = ref<dataSourceType[]>([]);
//模态框数据
const modAlProps = reactive<dataSourceType>({
  width: "L",
  title: "操作记录",
});
const getRecordValue = (key: number) => {
  // 1:编辑 2：发布 3：下线 4：提交审核 5：撤回审核 6：编辑后发布 7：编辑后提交审核
  return key == 1
    ? "编辑"
    : key == 2
    ? "发布"
    : key == 3
    ? "下线"
    : key == 4
    ? "提交审核"
    : key == 5
    ? "撤回审核"
    : key == 6
    ? "编辑后发布"
    : "编辑后提交审核";
};
const formState = ref<dataSourceType>({});
//模态框button按钮个数和文案修改

let buttons = ref<dataSourceType[]>([]);
let scroll: scrollType = reactive({ y: "", isFixed: false });
// 立即发布
const immediatelyRecord = () => {};
// 待发布
const waitRecord = () => {};
// 操作记录
const operatingRecord = () => {};
// 内容版本
const versionRecord = () => {};
// 删除
const deleteRecord = () => {};
const emits = defineEmits(["handleOk", "handleCancle"]);
const handleOk = () => {
  emits("handleOk");
};

const handleCancle = (e: MouseEvent) => {
  emits("handleCancle", e);
};
const fetchContentOpRecordList = async () => {
  let data = await request.fetchContentOpRecordList({ contentId: props.contentId });
  resData.value = data;
};
onMounted(async () => {
  fetchContentOpRecordList();
});
</script>

<style lang="less" scoped>
.operatingRecord_modal {
  .operatingRecordBox {
    height: 493px;
    overflow-y: auto;
  }
}
</style>
